package com.qianfeng.openplatform.zuul.feign;

import com.qianfeng.openplatform.zuul.feign.impl.CacheFeignImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

/**
 * @Author LJF
 * @Date 2020/8/4 19:28
 * @Version 1.0
 */
@Component
@FeignClient(value = "OPENAPI-CACHE", fallback = CacheFeignImpl.class)
public interface CacheFeign {

    @PostMapping("/cache/save2Redis/{key}/{value}/{expireTime}")
    boolean save2Redis(@PathVariable String key, @PathVariable String value, @PathVariable long expireTime) throws Exception;

    @GetMapping("/cache/getFromRedis/{key}")
    String getFromRedis(@PathVariable String key) throws Exception;

    @PostMapping("/cache/deleteKey/{key}")
    boolean deleteKey(@PathVariable String key) throws Exception;

    @PostMapping("/cache/expire/{key}/{expireTime}")
    boolean expire(@PathVariable String key, @PathVariable long expireTime) throws Exception;

    @PostMapping("/cache/getAutoIncrementId/{key}")
    Long getAutoIncrementId(@PathVariable String key) throws Exception;

    @PostMapping("/cache/sMembers/{key}")
    Set<Object> sMembers(@PathVariable String key) throws Exception;

    @PostMapping("/cache/sAdd/{key}/{value}/{expireTime}")
    Long sAdd(@PathVariable String key, @PathVariable String value, @PathVariable long expireTime) throws Exception;

    @PostMapping("/cache/sAdd/{key}/{expireTime}")
    Long sAdd(@PathVariable String key, @RequestParam("value") String[] value, @PathVariable long expireTime) throws Exception;

    @PostMapping("/cache/sRemove/{key}/{value}")
    Long sRemove(@PathVariable String key, @PathVariable String value) throws Exception;

    @PostMapping("/cache/hSet/{key}/{field}/{value}")
    void hSet(@PathVariable String key, @PathVariable String field, @PathVariable String value) throws Exception;

    @GetMapping("/cache/hGet/{key}/{field}")
    String hGet(@PathVariable String key, @PathVariable String field) throws Exception;

    @GetMapping("/cache/hGetAll/{key}")
    Map<Object, Object> hGetAll(@PathVariable String key) throws Exception;

    @PostMapping("/cache/setNX/{key}/{value}/{expireSecond}")
    boolean setNX(@PathVariable String key, @PathVariable String value, @PathVariable long expireSecond) throws Exception;

    @PostMapping("/cache/hMset/{key}")
    boolean hMset(@PathVariable String key, @RequestBody Map<Object, Object> map) throws Exception;

    @GetMapping("/cache/findKeyByPartten/{partten}")
    Set<String> findKeyByPartten(@PathVariable String partten) throws Exception;

    @PostMapping("/cache/hIncrement/{key}/{field}/{delta}")
    Long hIncrement(@PathVariable String key, @PathVariable String field, @PathVariable long delta) throws Exception;

    @PostMapping("/cache/hMset/{key}")
    boolean hMset(@PathVariable String key, @RequestBody Object map) throws Exception;

}
